#include<stdio.h>
struct node 
{
int data;
struct node *next;
} *p;

add(int num) //adding elements in linked list
   {
      	struct node *tmp;
        tmp=(struct node *)malloc(sizeof(struct node));
        tmp->data=num;
        if (p== NULL)
       {
          p=tmp;
          p->next=NULL;
       }
   	else
      {
	  tmp->next=p;
          p=tmp;
      }
   }



reverse(struct node *head) //reversing linked list
{
	struct node *m, *n,*l,*s;
   	m=head;
   	n=NULL;
  	while(m!=NULL)
 {
   	s=n;
   	n=m;
  	m=m->next;
  	n->next=s;
 }
   	p=n;
}


disp(struct node *r) //display linked list
{
      r=p;
      if(r==NULL)
     {
       printf("no elements!!!");
       return;
     }
    while(r!=NULL)
    {
      printf("%d",r->data);
      r=r->next;
    }
}
void main()
{
int n,i,n1;
printf("enter no. of nodes=");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter a number=");
scanf("%d",&n1);
add(n1);
}
reverse(p);
disp(p);
}

